package cn.yunhe.service;

import cn.yunhe.dao.FatherTypeDao;
import cn.yunhe.entity.FatherType;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class FatherTypeService {
    SqlSession session=SqlSessionFactoryUtil.getSqlSession();
    FatherTypeDao fatherTypeDao=session.getMapper(FatherTypeDao.class);

    public List<FatherType> findFatherType(){

        return fatherTypeDao.findFatherType();
    }

    public boolean addFatherType(FatherType fatherType){
        boolean flag = fatherTypeDao.addFatherType(fatherType);
        session.commit();
        session.close();
        return flag;
    }

    public  boolean  deleteFatherType(int typeid){
        boolean flag = fatherTypeDao.deleteFatherType(typeid);
        session.commit();
        session.close();
        return flag;
    }

    public boolean updateFatherType(String typename,int typeid){

        boolean flag = fatherTypeDao.updateFatherType(typename, typeid);
        session.commit();
        session.close();
        return flag;
    }
}
